/**
 * Created With IntelliJ IDEA
 * Description:牛客网：BM64 最小花费爬楼梯
 * https://www.nowcoder.com/practice/6fe0302a058a4e4a834ee44af88435c7?tpId=295&tqId=2366451&ru=/exam/oj&qru=/ta/format-top101/question-ranking&sourceUrl=%2Fexam%2Foj
 * User: DELL
 * Data: 2022-11-04
 * Time: 13:53
 */
import java.util.*;


public class Solution {
    /**
     * 代码中的类名、方法名、参数名已经指定，请勿修改，直接返回方法规定的值即可
     *
     *
     * @param cost int整型一维数组
     * @return int整型
     */
    public int minCostClimbingStairs (int[] cost) {
        int[] tmp = new int[cost.length + 1];
        //tmp[i]即表示跳到第i节台阶所需要的最低花费
        //题目中的意思是跳到第cost.length节台阶
        tmp[0] = 0;
        tmp[1] = 0;
        for (int i = 2; i <= cost.length; i++) {
            tmp[i] = Math.min(tmp[i - 1] + cost[i - 1],tmp[i - 2] + cost[i - 2]);
        }
        return tmp[cost.length];
    }
}